/*
 * Camera.cpp
 *
 *  Created on: 19-dec.-2013
 *      Author: Axel
 */

#include <Camera.h>

Camera::Camera() {
	trans = new Transform();

	resetPos();
	resetZoom();
	resetRot();

	trans->WorldPos(data.x, data.y, data.z);
	trans->Scale(data.scalex, data.scaley, data.scalez);
	trans->Rotate(data.rotx, data.roty, data.rotz);
}

Camera::~Camera() {
	delete trans;
}

void Camera::resetPos() {
	data.x = 0;
	data.y = 0;
	data.z = 0;
}

void Camera::resetZoom() {
	data.scalex = 1;
	data.scaley = 1;
	data.scalez = 1;
}

void Camera::resetRot() {
	data.rotx = 0;
	data.roty = 0;
	data.rotz = 0;
}

void Camera::move(float x, float y, float z) {
	//perhaps create bounderies

	data.x += x;
	data.y += y;
	data.z += z;
	trans->WorldPos(data.x, data.y, data.z);
}

void Camera::scale(float x, float y, float z) {
	data.scalex += x;
	data.scaley += y;
	data.scalez += z;
	trans->Scale(data.scalex, data.scaley, data.scalez);
}

void Camera::zoom(float percentage) {
	data.scalex += percentage;
	data.scaley += percentage;
	data.scalez += percentage/2;
	trans->Scale(data.scalex, data.scaley, data.scalez);
}

void Camera::rotate(float aroundx, float aroundy, float aroundz) {
	data.rotx += aroundx;
	data.roty += aroundy;
	data.rotz += aroundz;
	trans->Rotate(data.rotx, data.roty, data.rotz);
}

const Matrix4f* Camera::getCamera() {
	return trans->GetTrans();
}

void Camera::setPerspective(float FOV, float width, float height, float zNear, float zFar) {
	trans->SetPerspectiveProj(FOV, width, height, zNear, zFar);
}
